package com.eduardcapell.lopodder;


import java.util.List;

import com.eduardcapell.lopodder.beans.Feed;
import com.eduardcapell.lopodder.cli.CommandLineApp;
import com.eduardcapell.lopodder.db.DBAccess;
import com.eduardcapell.lopodder.gui.FrameApplication;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		startApp(args);
	}

	private static void startApp(String[] args) {
		// 1 - Load feeds from disk/database/etc.
		List<Feed> feeds = loadFeeds();
		
		// 2 - Check whether user wants GUI or just update everything (text-only)
		if (args != null && args.length > 0) {
			args[0] = args[0].toUpperCase();
			if (args[0].startsWith("T")) {
				// Text-only, update everything.
				new CommandLineApp(feeds);
			}
		} else {
			new FrameApplication(feeds).setVisible(true);
		}
	}

	private static List<Feed> loadFeeds() {
		return DBAccess.getAllFeeds();
	}
}
